home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 3903 < prev    next >
Encoding:
Text File  |  1996-08-06  |  2.0 KB  |  65 lines

  1. Path: nntp-trd.UNINETT.no!usenet
  2. From: frodeb@stud.idb.hist.no (Frode Breimo)
  3. Newsgroups: comp.lang.c++
  4. Subject: Q: Detecting keystrokes
  5. Date: Fri, 26 Jan 1996 17:07:51 GMT
  6. Organization: HiST
  7. Message-ID: <4eb1o9$4tf@doffen.uninett.no>
  8. NNTP-Posting-Host: pc164.idb.hist.no
  9. X-Newsreader: Forte Free Agent 1.0.82
  10.  
  11. OK. This is probably a simple question but here goes:
  12.  
  13. I've just started learning MS VC++ and want to write a DOS-program
  14. that reads the user's keystroke immediatley, without him having to
  15. press enter (and preferably without it even showing on the screen).
  16. This is meant to be a simple getkey program that reads a keystroke and
  17. uses it's ASCII-code as an exit-value for testing. I've tried several
  18. of the functions available, and even tried some of the examples
  19. provided in the help-files but nothing works. This is what I got so
  20. far:
  21.  
  22. #include <iostream.h>
  23. #include <stdio.h>
  24. #include <bios.h> 
  25.                                                        
  26. unsigned char Key;   // The key pressed.
  27. int KeyCode;             // The key's ASCII-code.
  28.  
  29. void main(void)
  30. {
  31. //   while( !(_bios_keybrd( _KEYBRD_SHIFTSTATUS ) & 0001) )
  32. //      printf( "Use the right SHIFT key to stop this message\n" );
  33. //   printf( "Right SHIFT key pressed\n" );
  34.   
  35. Key = _bios_keybrd(_NKEYBRD_READ);
  36. cout << Key;    // So far I'm just testing if the key was read
  37. correctly.
  38. }
  39.  
  40. (The three lines with // in front of are from an example taken from
  41. the help-files. It didnt work.)
  42.  
  43. This is what I get when I try to compile it:
  44.  
  45. Compiling...
  46. x:\dokument\c\getkey.cpp
  47. x:\dokument\c\getkey.cpp(25) : error C2065: '_bios_keybrd' :
  48. undeclared identifier
  49. x:\dokument\c\getkey.cpp(25) : error C2064: term does not evaluate to
  50. a function
  51.  CL returned error code 2.
  52. GETKEY.EXE - 2 error(s), 0 warning(s)
  53.  
  54. Line 25 is where the call to the _bios_keybrd function is. 
  55.  
  56. Can someone please help me with this?
  57.  
  58.  
  59. ---------------------------------------------------------------
  60. Frode Breimo
  61. e-mail: frodeb@stud.idb.hist.no
  62. www: http://www.idb.hist.no/~frodeb
  63. ---------------------------------------------------------------
  64.  
  65.